home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / Campaign3StartupOld.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  4.4 KB  |  172 lines

  1. --Common Level Start Code
  2. G.Create( "MenuData/HudCog.xml" );
  3. G.Create( "Data/GameCamera.xml" );
  4. G.Create( "Data/CursorCog.xml" );
  5.  
  6. MainLevel = G.Create( "Data/Levels/Campaign3/Campaign3.xml" );
  7. MainLevel.CreateLevel();
  8.  
  9.  
  10. G.SetInvSpeed( 20 );
  11. G.PlayMusic();
  12. HUD.EnterLevel();
  13. G.SetGameState( InLevel );
  14. G.SetPoints( 100 );
  15.  
  16. gameStartTime = 10000000;
  17.  
  18.  
  19. HUD.Message( "VictoryCondition" , "SetText", "Survive 3 minutes!"  );
  20. HUD.Message( "LossCondition" , "SetText", "If the Tower is destroyed you lose" );
  21.  
  22.  
  23. function LevelExitDesc()
  24.     if ( GameState == QuitLevel )then
  25.         G.ActiveBackGround( 2 );
  26.         return "YOU QUIT!";
  27.     elseif(  GameState == Victory )then
  28.         G.ActiveBackGround( 1 );
  29.         return "YOU WON!";
  30.     elseif( GameState == Defeat )then
  31.         G.ActiveBackGround( 2 );
  32.         return "YOU LOST!";
  33.     end
  34. end
  35.  
  36. function TraitorScript()
  37.  
  38.     LargeTextPopup( "Level 3:\n Special Delivery", Color(1,1,1,1) )
  39.     
  40.     G.DeactivateTrapDrop()
  41.     G.DisableTrapAll()
  42.     G.EnableTrap("wall");
  43.     G.EnableTrap("laser");
  44.     G.EnableTrap("spring");
  45.     DisableTraitor()
  46.     GameWait(.5)
  47.     EnableTraitor()
  48.     Traitor.SetGuiPosition( "TraitorWindow"  , Vector3(0.6, -0.5, 1) );
  49.     
  50.     TraitorTalk("*Yawn*  Hey, how're you?  I slept great last night, that couch is real comfy!")
  51.     GameWait(6)
  52.     TraitorTalk("How did that thing with the other Invaders go?")
  53.     GameWait(4)
  54.     TraitorTalk("You're still here, so I guess that means you won.  Good for you!")
  55.     GameWait(5)
  56.     TraitorTalk("...  and, good for me too, hehe.")
  57.     GameWait(3)
  58.     
  59.     --explosion
  60.     GameWait(1)
  61.     TraitorTalk("What was that?!")
  62.     GameWait(1)
  63.     --pan camera to kamikaze running into a wall
  64.     TraitorTalk("Oh no, they must be really mad now!")
  65.     GameWait(3)
  66.     TraitorTalk("They're sending in the demolitionists to try and tear down our defenses.")
  67.     GameWait(6)
  68.     TraitorTalk("Lets get this place into fighting shape!");
  69.     GameWait(3)
  70.     
  71.     -- drop springs
  72.     GameWait(3)
  73.     
  74.     TraitorTalk("Those Spring Traps alone wont be enough.")
  75.     GameWait(4)
  76.     TraitorTalk("These guys will probably just run right by 'em.")
  77.     GameWait(5)
  78.     TraitorTalk("Oh, wait a minute!  Here we go, try this...")
  79.     GameWait(3)
  80.     
  81.     -- drop fans
  82.     GameWait(3)
  83.     
  84.     TraitorTalk("These will help push all those hot-heads into the Spring Traps.")
  85.     GameWait(6)
  86.     TraitorTalk("Here, you better put some more down.")
  87.     GameWait(3)
  88.     
  89.     G.EnableTrap("fan")
  90.     -- explosion
  91.     GameWait(1)
  92.     
  93.     TraitorTalk("Yikes! Let me know when its over!")
  94.     GameWait(3)
  95.     DisableTraitor()
  96. end
  97.  
  98. function TraitorScript_InGame1()
  99.     EnableTraitor();
  100.     TraitorTalk("Boy those Kamikazes are fast!")
  101.     GameWait(3)
  102.     TraitorTalk("Be sure you get rid of them before they get to close to the tower.");
  103.     GameWait(6)
  104.     TraitorTalk("They can do some serious damage if they hit!");
  105.     GameWait(5)
  106.     DisableTraitor();
  107. end
  108.  
  109. function TraitorScript_InGame2()
  110.     EnableTraitor();
  111.     TraitorTalk("Those Bombers may look slow, but they pack a mighty wallop.")
  112.     GameWait(5)
  113.     TraitorTalk("They've got a countdown timer, and when it hits zero, they blow up!");
  114.     GameWait(6)
  115.     TraitorTalk("Almost makes you feel sorry for them, doesn't it.");
  116.     GameWait(5)
  117.     DisableTraitor();
  118. end
  119.  
  120.  
  121. local ingames = {};
  122.  
  123. function LevelVictory()
  124.     local tower = G.GetCogName("Tower");
  125.     
  126.     if( not tower.IsValid() ) then
  127.         G.SetGameState( Defeat );    
  128.     end
  129.  
  130.     if( GameTime - gameStartTime >= 180 ) then
  131.         G.SetGameState( Victory );    
  132.     end
  133.     
  134.     if( not( GameState == InLevel ) ) then
  135.         dofile( "Scripts/GameOver.lua" );        -- The gameover script should do all exit functionality:
  136.         GMain["LevelVictory"] = nil;
  137.     end    
  138.     
  139.     if(GameTime - gameStartTime > 15 and not (ingames[1] == 1)) then
  140.         ingames[1] = 1;
  141.         CreateCoroutine(TraitorScript_InGame1)
  142.     end
  143.     
  144.     if(GameTime - gameStartTime > 38 and not (ingames[2] == 1)) then
  145.         ingames[2] = 1;
  146.         CreateCoroutine(TraitorScript_InGame2)
  147.     end
  148. end
  149.  
  150.  
  151. storyroutine = coroutine.create(TraitorScript);
  152.  
  153. function StoryMode()
  154.     if( storyroutine ) then    
  155.         local con = coroutine.resume(storyroutine)
  156.         if( con == false ) then
  157.             gameStartTime = GameTime;
  158.             storyroutine = nil;
  159.             GMain["LevelVictory"] = nil;
  160.             DisableTraitor()
  161.             dofile( "Data/Levels/Campaign3/campaign3Spawners.lua" );
  162.             GMain["LevelVictory"] = LevelVictory;
  163.         end            
  164.         if( not( GameState == InLevel ) ) then
  165.             dofile( "Scripts/GameOver.lua" );        -- The gameover script should do all exit functionality:
  166.             GMain["LevelVictory"] = nil;
  167.         end            
  168.     end    
  169. end
  170.  
  171. GMain["LevelVictory"] = StoryMode;
  172.